//
//  LBUser.swift
//  LBNewWeiBo
//
//  Created by bin on 15/11/1.
//  Copyright © 2015年 bin. All rights reserved.
//

import UIKit

class LBUser: NSObject {

    //MARK: - 用户的属性
    ///字符串型的微博UID
    var idstr : String?
    //name	string	友好显示名称
    var name : String?
///profile_image_urlStr用户头像地址（中图），50×50像素
    var profile_image_url :String?
    /// verified_type 没有认证:-1   认证用户:0  企业认证:2,3,5  达人:220
    var verified_type :Int = -1
    
    /// 用户认证
    var verifiedTypeImage: UIImage?{
        switch verified_type {
        case 0:
            return UIImage(named: "avatar_vip") //认证用户
        case 2,3,5:
            return UIImage(named: "avatar_enterprise_vip") //企业
        case 220:
            return UIImage(named: "avatar_grassroot")
        default:
            return nil
        }
    }
    
    /// 会员等级
    var mbrank: Int = 0 // 默认
    
    /// 计算型属性，根据不同会员等级返回不同图片
    var mbrankImage: UIImage? {
        if mbrank > 0 && mbrank <= 6 {
            return UIImage(named: "common_icon_membership_level\(mbrank)")
        }
        
        return nil
    }
    
    //MARK: - 字典转模型
    /// 字典转模型
     init(dict:[String: AnyObject]) {
        super.init()
        
        // 调用kvc
        setValuesForKeysWithDictionary(dict)
    }
    
    /// 空实现
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    // description：输出打印
    override var description: String {
        let properties = ["idstr", "name", "profile_image_url", "verified_type", "mbrank"]
        
        return "\n\t用户模型：\(dictionaryWithValuesForKeys(properties))"
    }
    
    
    
}
